﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace FQY.Infrastructure.Core
{
    /// <summary>
    /// 系统环境
    /// </summary>
    public class SysHelper
    {
        /// <summary>
        /// 获取当前路径
        /// </summary>
        public static string CurPath
        {
            get
            {
                //判断是Web程序还是window程序
                if (HttpContext.Current != null)
                {
                    return CurWebPath;
                }
                else
                {
                    return CurClientPath;
                }
            }
        }

        /// <summary>
        /// 当前Web程序路径
        /// </summary>
        protected static string CurWebPath
        {
            get
            {
                return HttpRuntime.AppDomainAppPath;
            }
        }
        // 当前window程序路径
        protected static string CurClientPath
        {
            get
            {
                //string assemblyFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
                //string assemblyDirPath = Path.GetDirectoryName(assemblyFilePath);
                //return assemblyDirPath;

                return AppDomain.CurrentDomain.BaseDirectory;
            }
        }
        #region 获取GUID值  
        /// <summary>  
        /// 获取GUID值  
        /// </summary>  
        public static string NewGUID
        {
            get
            {
                return Guid.NewGuid().ToString();
            }
        }
        #endregion

    }
}
